// ignore_for_file: must_be_immutable

/*
 * @Author: CodeHare
 * @Date: 2023-11-20 14:19:16
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2024-04-25 10:01:49
 * @Description: 报障单列表
 */
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:yt_devops/resources/str_res_keys.dart';
import 'package:yt_devops/styles/styles.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:yt_devops/pages/tasks/my_fault_report/fault_report_list_state.dart';
import 'package:yt_devops/utils/func_utils.dart';

class FaultReportItemWidget extends StatelessWidget {
  final FaultReportItemModel model;
  void Function(FaultReportItemModel, BuildContext)? onItemTaped;
  FaultReportItemWidget(this.model, {this.onItemTaped, super.key});

  @override
  Widget build(BuildContext context) {
    var labelWith = FuncUtils.getWidthByLocal(75.w, 120.w);
    return GestureDetector(
      child: Container(
        padding: EdgeInsets.fromLTRB(16.w, 0, 16.w, 0),
        margin: const EdgeInsets.only(top: 10),
        color: Colour.white,
        child: Column(
          children: [
            SizedBox(
              height: 53,
              child: Row(
                children: [
                  Expanded(
                    child: Text(
                      model.siteName ?? '',
                      style: TextStyle(
                          color: Colour.mainTextColor,
                          fontSize: 18.sp,
                          fontWeight: FontWeight.w500),
                      overflow: TextOverflow.ellipsis,
                    ),
                  ),
                  // Padding(
                  //   padding: EdgeInsets.only(left: 10.w),
                  //   child: statusWidget(context),
                  // )
                ],
              ),
            ),
            Padding(
              padding: const EdgeInsets.only(bottom: 8),
              child: Row(
                children: [
                  SizedBox(
                    width: labelWith,
                    child:
                        Text(ResKey.workOrderCode.tr, style: TextStyles.lf14),
                  ),
                  Expanded(
                    child: Text(
                      model.id.toString(),
                      style: TextStyle(
                        color: Colour.mainTextColor,
                        fontSize: 14.sp,
                      ),
                      overflow: TextOverflow.ellipsis,
                    ),
                  )
                ],
              ),
            ),
            Padding(
              padding: const EdgeInsets.only(bottom: 8),
              child: Row(
                children: [
                  SizedBox(
                    width: labelWith,
                    child: Text(ResKey.failureTitle.tr, style: TextStyles.lf14),
                  ),
                  Expanded(
                    child: Text(
                      model.name ?? '',
                      style: TextStyle(
                        color: Colour.mainTextColor,
                        fontSize: 14.sp,
                      ),
                      overflow: TextOverflow.ellipsis,
                    ),
                  )
                ],
              ),
            ),
            Padding(
              padding: const EdgeInsets.only(bottom: 8),
              child: Row(
                children: [
                  SizedBox(
                    width: labelWith,
                    child: Text(ResKey.curWorkOrderStatus.tr,
                        style: TextStyles.lf14),
                  ),
                  Expanded(
                    child: Text(
                      model.status!.label,
                      style: TextStyle(
                        color: Colour.mainTextColor,
                        fontSize: 14.sp,
                      ),
                      overflow: TextOverflow.ellipsis,
                    ),
                  )
                ],
              ),
            ),
            Padding(
              padding: const EdgeInsets.only(bottom: 8),
              child: Row(
                children: [
                  SizedBox(
                    width: labelWith,
                    child:
                        Text(ResKey.declarationTime.tr, style: TextStyles.lf14),
                  ),
                  Expanded(
                    child: Text(
                      model.createTime!,
                      style: TextStyle(
                        color: Colour.mainTextColor,
                        fontSize: 14.sp,
                      ),
                      overflow: TextOverflow.ellipsis,
                    ),
                  )
                ],
              ),
            ),
          ],
        ),
      ),
      onTap: () {
        if (onItemTaped != null) {
          onItemTaped!(model, context);
        }
      },
    );
  }

  // Widget statusWidget(BuildContext context) {
  //   return GestureDetector(
  //     onTap: () {
  //       if (onItemTaped != null) {
  //         onItemTaped!(model, context);
  //       }
  //     },
  //     child: Container(
  //       alignment: Alignment.center,
  //       padding: EdgeInsets.symmetric(horizontal: 4.w),
  //       height: 20.h,
  //       child: Image(
  //         image: const AssetImage(ImageAssets.iconUnbindingDevice),
  //         height: 20.w,
  //         width: 20.w,
  //       ),
  //     ),
  //   );
  // }
}
